<template>
  <div class="f3usercontainer">
    <template v-if="!unickname">
      <div class="login-info">
        <div class="login-text">登录后，头条更懂你<br />内容更有趣</div>
        <router-link to="/login" class="login-button">
          <a>立即登录</a>
        </router-link>
      </div>
    </template>
    <template v-else>
      <div class="user-info">
        <div class="title">欢迎光临俄乌局势观察网!</div>

        <div class="info">
          <div class="ulogo">
            <router-link :to="`/userpage/?uid=${uid}`">
              <img :src="ulogo" alt="" />
            </router-link>
          </div>
          <ul>
            <li>用户名：{{ unickname }}</li>
            <li>邮&nbsp;&nbsp;&nbsp;&nbsp;箱：{{ uemail }}</li>
          </ul>
        </div>
        <div class="exit-btn" @click="logout">退出登录</div>
      </div>
    </template>
  </div>
</template>
<script>
import { mapState } from "vuex";
export default {
  data() {
    return {
      ulogo: "https://p3.toutiaoimg.com/img/3793/3131589739~0x0.image",
    };
  },
  computed: {
    ...mapState(["unickname", "uemail", "uid"]),
  },
  methods: {
    logout() {
      this.$store.commit("logoutUser");
    },
  },
  mounted() {
    if (this.$store.state.ulogo != "null") {
      console.log("1231");

      this.ulogo = this.$store.state.ulogo;
    }
  },
};
</script>

<style lang="scss" scoped>
.login-info {
  height: 180px;
  background-color: rgb(250, 250, 250);
  text-align: center;
  border: 1px solid rgb(205, 205, 205);
  border-radius: 10px;
  overflow: hidden;
  > .login-text {
    padding-top: 60px;
    background-size: contain;
    background-repeat: no-repeat;
    background-image: url("../assets/img/f3/登录信息背景.svg");
    font-size: 18px;
    line-height: 24px;
    color: #505050;
  }
  > .login-button {
    display: inline-block;
    margin: 0px auto;
    margin-top: 10px;
    background-color: rgb(144, 8, 14);
    border-radius: 6px;
    font-size: 16px;
    line-height: 24px;
    padding: 8px 32px;
    width: 128px;
    cursor: pointer;
    user-select: none;
    > a {
      color: white;
    }
  }
}
.user-info {
  height: 180px;
  text-align: center;
  border: 1px solid rgb(205, 205, 205);
  border-radius: 10px;
  background-color: rgb(250, 250, 250);
  .ulogo {
    width: 60px;
    height: 60px;
    overflow: hidden;
    border: 2px solid white;
    border-radius: 50%;
    img {
      height: 60px;
      width: 60px;
    }
  }
  > .title {
    margin-top: 17px;
    color: rgb(144, 8, 14);
    font-size: 18px;
    font-weight: bold;
  }
  > .info {
    text-align: left;
    color: rgb(144, 8, 14);
    margin-left: 30px;
    margin-top: 15px;
    display: flex;
    li {
      width: 210px;
      margin-left: 10px;
      margin-top: 10px;
      margin-bottom: 10px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  > .exit-btn {
    margin: 0 auto;
    margin-top: 15px;
    background-color: #90080e;
    color: white;
    border-radius: 6px;
    line-height: 30px;
    width: 128px;
    cursor: pointer;
    padding: 7px 30px;
  }
}
</style>
